<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>啄木鸟管理平台</title>
    <th:block th:replace="common/common :: jscss"/>
</head>

<body>
<div class="layui-row">
    <div class="layui-card" style="padding-bottom: 25px;">
        <div class="layui-card-body">
            <form method="POST" action="" class="layui-form" lay-filter="zmn-form">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width:100px">已关闭日期：</label>
                    <div class="layui-input-inline" style="width:800px">
                        <input type="checkbox" name="ids" th:each="item:${closeList}"
                                th:value="${item.id}"
                                th:title="${#dates.format(item.day, 'yyyy-MM-dd')}">
                    </div>
                </div>
                <div class="layui-form-item  submit">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="zmn-form-submit">开启</button>
                        <a class="layui-btn layui-btn-primary" onclick="zmnLayUtil.closeThisIframe(parent)">取消</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script type="text/javascript" th:inline="javascript">

    var json = {
        submitURL: [[${submitURL}]],
    };

    layui.config({
        base: "/static/lay/"
    }).extend({
        index: "lib/index"
    }).use(['index', 'form'], function(){
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;

        // 提交
        form.on('submit(zmn-form-submit)', function(obj){
            var data = obj.field;
            console.log('1')
            //获取checkbox[name='ids']的值
            var ids = new Array();
            $("input:checkbox[name='ids']:checked:not(:disabled)").each(function(i){
                ids[i] = $(this).val();
            });
            var url = json.submitURL;
            $.ajax({
                async: false,
                type: "POST", url: url,
                contentType: "application/json", dataType: "json", data: JSON.stringify(ids),
                success:function(resp) {
                    if(resp.status == 200) {
                        zmnPage.reload('操作成功!', 1000)
                    }else{
                        layer.msg(resp.message,{icon: 2});
                    }
                },
                error:function(XMLHttpRequest, status, errorThrown){}
            });
            return false;
        });
    });
</script>

</body>
</html>